#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 vagrant
#
# Distributed under terms of the MIT license.

from django.core.management.base import BaseCommand, CommandError, NoArgsCommand
from esr_parser import shortcuts
from esr_parser import core


class Command(BaseCommand):

    def add_arguments(self, parser):
        parser.add_argument('url', type=str)

    def handle(self, *args, **options):
        url = options.get('url')
        pid = core.get_item_id(url)
        is_tm = 'tmall' in url

        print shortcuts.item_detail(pid, is_tm, None)

